import { reqPostSearch } from '@/api/index';
const actions = {
    //params={} 当调用者没有传参数时，默认为{}
    async getSearch(context, params = {}) {
        let result = await reqPostSearch(params);
        if (result.code == '200') {
            context.commit('GETSEARCH', result.data)
        }
    }
}
const mutations = {
    GETSEARCH(state, searchData) {
        state.searchData = searchData
    }
}
const state = {
    searchData: {}
}
const getters = {
    goodsList(state) {
        return state.searchData.goodsList || [] //当state里的数据因各种原本没有存储返回空数组[]
    },
    trademarkList(state) {
        return state.searchData.trademarkList
    },
    attrsList(state) {
        return state.searchData.attrsList
    },
}
export default {
    namespaced: true,// 开启命名空间
    actions, mutations, state, getters
}